package com.ermao.mymes.handler.handler;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 全局唯一的 HandlerHolder，里面根据渠道类型存储了各种 handler
 * @author Ermao
 * Date: 2022/5/8 14:41
 */
@Component
public class HandlerHolder {
	private Map<Integer, Handler> handlers = new HashMap<>(32);

	public void putHandler(Integer channelCode, Handler handler) {
		handlers.put(channelCode, handler);
	}

	public Handler route(Integer channelCode) {
		return handlers.get(channelCode);
	}
}
